<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="yongjian.drp.model.User" %>
<%@ taglib uri="/struts-tags" prefix="s" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

User user = (User)session.getAttribute("user");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'user_add.jsp' starting page</title>
    
    <link rel="stylesheet" type="text/css" href="js/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="js/themes/icon.css">
    <script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="js/locale/easyui-lang-zh_CN.js"></script>
    
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript">
		$(function(){
			  $.extend($.fn.validatebox.defaults.rules, {   	
				      minLength: {   	
				          validator: function(value, param){   	
				              return value.length >= param[0];   	
				          },   	
				          message: ''  	
				      }  ,
				      equalTo:{
				    	  validator:function(value,param){
				    		 return $(param[0]).val() == value;
				    	  },
				    	  message:''
				      }
				  }); 
			  $('#btn').click(function(){
					$('#myform').form('submit',{
							url:'json/user_pwModify.action' , 
							onSubmit:function(){
								if(!$('#myform').form('validate')){
									return false ;		//当表单验证不通过的时候 必须要return false 
								}
							} ,
							success:function(result){
								var result = $.parseJSON(result);
								if(result.status == "fail"){
									document.getElementById("error").innerHTML = result.msg;								
								} else {									
									location.reload(true);
									alert("成功");
								}
							}
					});
				});
		});
	</script>

  </head>
  
  <body> 
	<hr>
	<center>
	  	<form id="myform" action="" method="post">
	  	<input type="hidden" name="user.id" value="<%= user.getId()%>">
	  		<table>
	  			<tr>
	  				<td>旧密码</td>
	  				<td>
	  					<input type="password" name="oldPassword" class="easyui-validatebox" required=true 
	  						missingMessage="旧密码必填">
	  					<font color="red"><span id="error"></span></font>
	  				</td>
	  			</tr>
	  			<tr>
	  				<td>新密码</td>
	  				<td>
	  					<input type="password" id="password" name="user.password" class="easyui-validatebox" required=true 
	  						missingMessage="新密码必填" validType="minLength[5]" invalidMessage="新密码至少5个字符">
	  				</td>
	  			</tr>
	  			<tr>
	  				<td>密码确认</td>
	  				<td>
	  					<input type="password" name="user.password1" class="easyui-validatebox" required=true 
	  						missingMessage="请确认密码" validType="equalTo['#password']" invalidMessage="两次密码输入不一致">
	  				</td>
	  			</tr>	  		
	  			<tr>
	  				<td></td>
	  				<td>
	  					<a id="btn" class="easyui-linkbutton">保存</a>
	  				</td>
	  			</tr>
	  		</table>	
	  	</form>	
  	</center>
  	
  </body>
</html>
